package com.zws.cucumber.plugin;

import io.cucumber.plugin.event.EventPublisher;

import java.util.Iterator;
import java.util.List;

public class ZwsPluginChainDefaultImpl implements ZwsPluginChain {

    private final Iterator<ZwsPlugin> iterator;

    public ZwsPluginChainDefaultImpl(List<ZwsPlugin> pluginList) {
        iterator = pluginList.iterator();
    }

    @Override
    public void invokeNext(EventPublisher publisher) {
        if (iterator.hasNext()) {
            ZwsPlugin plugin = iterator.next();
            plugin.init(this, publisher);
        }
    }
}
